package org.jeecg.modules.chargeWater.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.chargeWater.entity.ChargeWater;
import org.jeecg.modules.chargeWater.mapper.ChargeWaterMapper;
import org.jeecg.modules.chargeWater.service.IChargeWaterService;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Description: 水价方案
 * @Author: jeecg-boot
 * @Date:   2023-06-19
 * @Version: V1.0
 */
@Service
public class ChargeWaterServiceImpl extends ServiceImpl<ChargeWaterMapper, ChargeWater> implements IChargeWaterService {
    public void updateStatus(ChargeWater chargeWater){
        if ("默认方案".equals(chargeWater.getStatus())){
            ChargeWater water = new ChargeWater();
            water.setStatus("备用方案");
            water.setType(chargeWater.getType());
            baseMapper.updateStatus(water);
        }
    }

    @Override
    public Map<String, Object> getWaterProgramme() {
        LambdaQueryWrapper<ChargeWater> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(ChargeWater::getStatus, "默认方案").eq(ChargeWater::getType, "自来水");
        return baseMapper.selectMaps(queryWrapper).get(0);
    }

    @Override
    public Map<String, Object> getRecycledProgramme() {
        LambdaQueryWrapper<ChargeWater> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(ChargeWater::getStatus, "默认方案").eq(ChargeWater::getType, "中水");
        return baseMapper.selectMaps(queryWrapper).get(0);
    }


}
